﻿layui.define(['element', 'jquery'], function (exports) {
    var element = layui.element,
        $ = layui.jquery;
    var obj = {
        getUrlParam: function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURIComponent(r[2]);
            return null;
        }, clearToText: function (moretext) {
            moretext = moretext.replace(/[\'\"\\\/\b\f\n\r\t]/g, '');// 去掉转义字符 
            moretext = moretext.replace(/[\-\_\,\!\|\~\`\(\)\#\$\%\^\&\*\{\}\:\;\"\L\<\>\?]/g, '');// 去掉特殊字符



            moretext = moretext.replace(/<meta(\n|.)*?>/ig, "");
            moretext = moretext.replace(/<!(\n|.)*?>/ig, "");
            moretext = moretext.replace(/<style[^>]*>(\n|.)*?<\/style>/ig, "");
            moretext = moretext.replace(/<script[^>]*>(\n|.)*?<\/script>/ig, "");
            moretext = moretext.replace(/<w:[^>]+>(\n|.)*?<\/w:[^>]+>/ig, "");
            moretext = moretext.replace(/<xml>(\n|.)*?<\/xml>/ig, "");
            moretext = moretext.replace(/\r\n|\n|\r/ig, "");

            moretext = moretext.replace("[\\pP+~$`^=|<>～｀＄＾＋＝｜＜＞￥×]", "");
            moretext = moretext.replace("[\\p{P}+~$`^=|<>～｀＄＾＋＝｜＜＞￥×]", "");   
            moretext = moretext.replace("\\p{Punct}", "");
            moretext = moretext.replace("\\pP", "");
            moretext = moretext.replace("\\p{P}", "");  
            
            moretext = moretext.replace(/<[^>]+>|&[^>]+;/g, "")

            moretext = moretext.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
            moretext = moretext.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
            moretext = moretext.replace(/(^\s*)|(\s*$)/g, ""); 
            moretext = moretext.replace(/(^\s*)/g, ""); 
            moretext = moretext.replace(/(\s*$)/g, ""); 
            moretext = moretext.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); //去掉空格
            moretext = moretext.replace(/\ +/g, "") //去掉空格
            moretext = moretext.replace(/[ ]/g, "")//去掉空格
            moretext = moretext.replace(/[\r\n]/g, "")//去掉回车换行
            moretext = moretext.replace(/\n[\s| | ]*\r/g, ''); //去除多余空行
            moretext = moretext.replace(/ /ig, ''); //去掉
            moretext = moretext.replace(/-/g, '') //去掉"-"号          
            

            return moretext;
        }, bb: function () {
            alert("bb");
        }
    };
    exports('jqx', obj);
}); 